package com.youlu.campus.entity;

import com.youlu.campus.base.base.EntityBase;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 * 用户扩展信息
 */
@Data
@Document(collection = "user_info_extend")
public class UserInfoExtend extends EntityBase {

    private String openId;

    @Indexed(unique = true)
    private String userId;
    /**
     * 来源与哪个
     */
    @Indexed
    private String appId="1112166368";

    private String name;

    /**
     * 姓名-英文名称
     */
    private String enName;

    @Indexed
    private String mobile;

    private String universityId;

    private String universityName;

    /**
     * 大学英文名称
     */
    private String enUniversityName;

    private String grade;

    private String nickName;

    private String avatarUrl;

    private String platform="qq";

    private String majorId;

    private String majorName;

    private Integer updateNameCount=0;

    private Boolean perfectInfoAddPoint = Boolean.FALSE;

    @Transient
    private Boolean userInfoComplete = Boolean.FALSE;

    /**
     * 是否绑定
     */
    @Transient
    private Boolean binded = Boolean.FALSE;

    /**
     * 城市
     */
    protected String city;
    /**
     * 省份
     */
    protected String province;
    /**
     * 区
     */
    protected String area;
    /**
     * 国家
     */
    protected String country;
    /**
     * email
     */
    protected String email;
    /**
     * 详细地址
     */
    protected String address;

    private String receiveName;

    private String receiveMobile;

    /**
     * 电子证书类型 默认中文版本
     */
    @Transient
    private String digitalCaType;

    @Transient
    private String miniVersion;




    /**
     * 验证用户信息是否完整
     */
    public void checkUserInfoComplete(){
        String [] checkParams = new String[]{this.name,this.universityId,this.universityName,this.grade,
                this.majorId,this.majorName};
        this.userInfoComplete = StringUtils.isAnyBlank(checkParams);
    }

    public Boolean checkUserInfo() {
        return StringUtils.isAllBlank(this.name, this.universityName);
    }

    public Boolean checkUserAdress() {
        return StringUtils.isNotBlank(this.receiveMobile)&&StringUtils.isNotBlank(this.receiveName)&&StringUtils.isNotBlank(this.address);
    }

}
